package com.mapper;

import com.javabean.Users;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author: 张波
 * @Time: 2025/8/28 12:13
 */
public interface UserMapper {
	/// 根据账号查询信息
	@Select("select * from project.users where username=#{arg0} and password=#{arg1} and status=1;")
	Users selectByUserNameAndPassword(String username,String password);
	/// 查询所有用户所有信息
	List<Users> selectAll();
	/// 用户修改
	/// 根据id进行查询
	@Select("select * from users where id=#{id}")
	Users selectById(int id);
	/// 根据id进行修改
//	@Update("update users set username = #{username},password=#{password},email=#{email},phoneNum=#{phoneNum},status=#{} where id=#{id}")
	/// 根据id删除
	@Delete("delete from users where id=#{id}")
	int deleteById(int id);
	/// 添加用户
	int insertUsers(Users users);
	@Insert("insert into users_role (userId,roleId)values(#{arg0},#{arg1})")
	int insertU_R(int usersId,int roleId);
	Users selectById2(int id);
	@Update("update users set email=#{email}, username=#{username}, password=#{password}, phoneNum=#{phoneNum}, status=#{status} where id=#{id}")
	int updateUsers(Users users);
	@Update("update users_role set roleId=#{arg1} where userId=#{arg0}")
	int updateU_R(int usersId,int roleId);
}
